home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 223_01 / fc.c < prev    next >
Text File  |  1980-01-01  |  1KB  |  42 lines

  1. /*
  2. ** fc.c        File Copy Program    by F.A.Scacchitti  3/5/86
  3. **
  4. **        Written in Small-C  Version 2.5 or later
  5. **
  6. **        Copies file from file to file
  7. **        Byte modifications may be made during transfer
  8. **
  9. **    printf may be substituted for prntf  (fas)
  10. **
  11. */
  12.  
  13. #include <stdio.h>
  14.  
  15.  
  16. main(argc,argv) int argc; char *argv[]; {
  17.  
  18. FILE fdin, fdout;    /* file  i/o channel pointers */
  19. char c;
  20.  
  21.    if (argc != 3)     {
  22.       prntf("\nfc usage: fc <source file> <new file> <CR>\n");
  23.       exit();
  24.    }
  25.    if((fdin = fopen(argv[1],"r")) == NULL) {
  26.       prntf("\nUnable to open file %s\n",argv[1]);
  27.       exit();
  28.    }
  29.    if((fdout = fopen(argv[2],"w")) == NULL) {
  30.       prntf("\nUnable to create file %s.\n",argv[2]);
  31.       exit();
  32.    }
  33.  
  34.    while((c = fgetc(fdin)) != EOF)
  35.  
  36.       fputc(c,fdout);
  37.  
  38.    fclose(fdin);
  39.    fclose(fdout);
  40. }
  41.  
  42.